import Vue from 'vue'
import Router from 'vue-router'
import Main from '@/views/main'
import Cookies from 'js-cookie'
import layout from '@/components/layout'
import audio_edit from '@/components/audio_edit'
import audio_format from '@/components/audio_format'

Vue.use(Router);
Vue.prototype.Cookies = Cookies;
Vue.prototype.basicpathRouter = [];

export const basicpath = [
	{
		path: '/main',
		icon: 'calculator',
		name: 'main',
		meta: {role: 'ROLE_ADMIN'},
		title: 'main',
		component: Main,
		redirect: '/main',
		children: [
			{
				path: '/main',
				icon: 'calculator',
				name: '/main',
				title: '任务中心',
				meta: {
					title: ['音频剪辑合成工具'],
					role: 'ROLE_ADMIN',
					requireAuth: true
				},
				component: resolve=> {require(['@/views/home'], resolve);}
			}
		]
	},
];

const normal = {
  path: '/',
  redirect: '/login'
}

const freeurl = [
  {
    path: '/login',
    name: 'login',
    component: resolve=> {require(['@/views/login'], resolve);},
  },
  {
    path: '/main',
    name: 'root',
    component: Main,
    children: [{
      path: '/main/merge',
      icon: '',
      name: 'merge',
	  title: 'merge',
		meta: {
			title: ['音频剪辑合成工具'],
			role: 'ROLE_ADMIN',
			requireAuth: true
		},
      component: resolve=> {require(['@/views/home'], resolve);},
    }]
},
{
	path: '/audio',
	icon: 'calculator',
	name:'音频',
	component: layout,
	children: [
	  {
		path: '/audio_edit',
		name:"音频编辑",
		component: audio_edit,
		meta: {
			title: ['音频编辑'],
			role: 'ROLE_ADMIN',
			requireAuth: true
		},
	  },
	  {
		path: '/audio_format',
		name:"音频格式转换",
		component: audio_format,
		meta: {
			title: ['音频格式转换'],
			role: 'ROLE_ADMIN',
			requireAuth: true
		},
	  }
	]
  },

];

const basicpathCopy = [].concat([]);

export const rules = basicpathCopy.concat(freeurl);

export default new Router({
  routes: rules.concat([normal])
})
